package 斗地主;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class test {
    //牌库
    public static List<card> allCard=new ArrayList<>();
    //做牌
    static {
       String[] size=new String[]{"3","4","5","6","7","8","9","J","Q","K","A","2"};
       String[] color=new String[]{"♦","♣","♥","♠"};
       int n=0;
        for (String s : size) {
            n++;
            for (String s1 : color) {
                card t=new card(s,s1,n);
                allCard.add(t);
            }
        }
        //大小王
        allCard.add(new card("","小王",++n));
        allCard.add(new card("","大王",++n));
        System.out.println(allCard);

    }
    public static void main(String[] args) {
        Collections.shuffle(allCard);
        System.out.println(allCard);
        //三个玩家
        List<card> a=new ArrayList<>();
        List<card> b=new ArrayList<>();
        List<card> c=new ArrayList<>();
        //发牌
        for (int i = 0; i < allCard.size()-3; i++) {
            if(i%3==0){
                a.add(allCard.get(i));
            }else if(i%3==1){
                b.add(allCard.get(i));
            }else {
                c.add(allCard.get(i));
            }
        }
        List<card> last=allCard.subList(allCard.size()-3,allCard.size());
        sortCard(a);
        sortCard(b);
        sortCard(c);
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(last);

    }
    public static void sortCard(List<card> s){
        s.sort((o1,o2)-> o2.getIndex()-o1.getIndex());
    }
}
